<include file="Public/head"/>
<link type="text/css" rel="stylesheet" href="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.css" />
<script src="{:get_style_cdnurl()}paimai/yunying/plugin/select2/select2.js" type="text/javascript"></script>
<style type="text/css">
    .select_model{
        -moz-appearance: none;background: rgba(0, 0, 0, 0) url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 115px 5px;
        border: 1px solid #d7d7d7; float: left;height: 26px;line-height: 26px;margin-right: 8px;margin-left:10px;text-indent: 2px;width: 136px;}
    .select2-container .select2-choice{ background: #fff url("{:get_style_cdnurl()}paimai/yunying/images/sanjiao.jpg") no-repeat scroll 132px 5px;width: 140px;}
</style>
<include file="Public/common_header"/>
<div class="mian">
    <include file="Public/sidebar" menu="rzgl.csdrz"/>
    <div class="mianR">
        <div class="yuyue">
            <ul>
                <li onclick="get_list(1);" class="yuCurrent">待认证</li>
                <li onclick="get_list(2);">认证跟踪</li>
                <li onclick="get_list(3);">跟踪成功</li>
                <li onclick="get_list(4);">跟踪失败</li>
            </ul>
        </div>

        <div class="yuList">
            <div class="yuSuo clearfix" style="float:left;">
                <input id="status" name="status" type="hidden" value="{$params.status|default=1}"/>
                <input type="text" id="dealer_id" name="dealer_id" placeholder="请输入车商ID" value="" class="suoDian" />
                <input type="text" id="phone" name="phone" placeholder="请输入手机号" value="" class="suoDian" />
                <select name="business_city" id="business_city" class="select_model">
                    <if condition="count($bc_city) gt 1">
                        <option value="0">请选择经营城市</option>
                    </if>
                    <volist name="bc_city" id="city">
                        <option value="{$key}">{$city}</option>
                    </volist>
                </select>
                <select id="manager_id" name="manager_id" style="float: left;margin-left: 5px;">
                    <option value="">请选择客户经理</option>
                    <?php foreach($manager_list as $man):?>
                    <option value="{$man.emp_id}">{$man.real_name}</option>
                    <?php endforeach;?>
                </select>
                <script>$("#manager_id").val("{$params.manager_id}");</script>
                <input type="text" id="start_time" name="start_time" value="" readonly placeholder="注册开始时间" style="margin-left: 10px;"/><em></em>
                <input type="text" id="end_time" name="end_time" value="" readonly placeholder="注册结束时间" style="margin-right: 10px;"/>
                <input type="button" id="search" value="搜索" class="suoSou">
            </div>

            <div class="listBox" id="listBox">

            </div>
        </div>
        <div class="clear"></div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        $("#manager_id").select2();
    });
    $("#start_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });
    $("#end_time").ymdateplugin({
        changeMonth: true,
        changeYear: true
    });

    function get_page(p){
        var status = $("#status").val();
        var url = get_url();
        url += "&p=" + p;
        $.get("/CarDealerWaitCertify/wait_certify_list?status=" + status, encodeURI(url), function(data){
            $("#listBox").html(data);
        },"html");
    }
    get_list(1);
    function get_list(status){
        change_tabs(status);
        $("#status").val(status);
        var url = get_url();
        $.get("/CarDealerWaitCertify/wait_certify_list?status=" + status ,url,function(data){
            $("#listBox").html(data);
        },"html");
    }
    function get_url(){
        var url = "";
        var business_city = $("#business_city").val();
        var dealer_id = $("#dealer_id").val();
        var phone = $("#phone").val();
        var manager_id = $("#manager_id").val();
        var start_time = $("#start_time").val();
        var end_time = $("#end_time").val();
        if (business_city > 0) {
            url += '&business_city=' + business_city;
        }
        if (dealer_id) {
            url += '&dealer_id=' + dealer_id;
        }
        if (phone) {
            url += '&phone=' + phone;
        }
        if (manager_id) {
            url += '&manager_id=' + manager_id;
        }
        if (start_time) {
            url += '&start_time=' + start_time;
        }
        if (end_time) {
            url += '&end_time=' + end_time;
        }
        return url;
    }

    $('#search').on('click',function(){
        var status = $("#status").val();
        get_list(status);
        // clear_params();
    });

    function change_tabs(status){
        if(status == 1){
            var start_placeholder = '注册开始时间';
            var end_placeholder = '注册结束时间';
        }else if(status == 2){
            var start_placeholder = '跟踪开始时间';
            var end_placeholder = '跟踪结束时间';
        }else if(status == 3){
            var start_placeholder = '申请开始时间';
            var end_placeholder = '申请结束时间';
        }else if(status == 4){
            var start_placeholder = '失败开始时间';
            var end_placeholder = '失败结束时间';
        }
        $("#start_time").attr('placeholder',start_placeholder);
        $("#end_time").attr('placeholder',end_placeholder);
        if($("#status").val() != status){
            clear_form_params();
        }
    }
    function clear_form_params(){
        $(':input').not(':button, :submit, :reset, :hidden, select').val('');
        if($("#business_city option").length > 1){
            $("#business_city").val(0);
        }
    }
</script>
<include file="Public/foot"/>